<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib  uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> 
<%
String path = request.getContextPath()+request.getServletPath().substring(0,request.getServletPath().lastIndexOf("/")+1);
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path;
%>    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>帖子</title>
</head>
<script type="text/javascript" src="<%=basePath%>js/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="<%=basePath%>My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript">
	function page(currentPage){
		$("#pageNumber").val(currentPage);
		$("#searchForm").submit();
	}
	function chongzhi(){
	}
	
	//进入修改页面
	function changepassword(){
		var id = $("#userid").val();
		window.location.href="<%=basePath%>user/edit/\""+id+"\"";
	}
	//添加新纪录
	function luru(){
		window.location.href="<%=basePath%>article/add"; 
	}
	
	function logout(){
		window.location.href="<%=basePath%>user/logout"; 
	}
</script>
<body>
<div style="height:700px;margin-top: 80px;" align="center">
	<div style="height:50px;padding-bottom: 0px;">
		<form action="<%=basePath%>article/list" name="searchForm" id="searchForm" method="post">
			<input type="hidden" name="pageNumber" value="1" id="pageNumber"/>
			<input type="hidden" name="pageSize" value="15" />
			<input type="button" value="查询" onclick="page(1)"/>
			<input type="button" value="修改密码" onclick="changepassword();">
			<input type="button" value="我要发帖" onclick="luru();">
			<input type="button" value="退出登录" onclick="logout();">
			<hr/>
		</form>
	</div>
	<c:if test="${page.totalRow > 0}">
	<div style="height:500px;" >
		<table border="0" cellpadding="4" cellspacing="4" width="100%" align="center">
			<tr>
				<th>点击数</th>
				<th>回复数</th>
				<th>标题</th>
				<th>作者</th>
				<th>发布日期</th>
				<th>最后回复人</th>
				<th>最后回复日期</th>
			</tr>
			<c:forEach items="${page.list}" var="article" varStatus="status">
				<tr>
					<td align="center">${article.view }</td>
					<td align="center">${article.reply }</td>
					<%-- <td align="center">${status.index+1+(page.pageNumber-1)*page.pageSize}</td> --%>
					<td align="center"><a href="<%=basePath%>article/detail/${article.id}">${article.title }</a></td>
					<td align="center">${article.author }</td>
					<td align="center">${article.publish_date }</td>
					<td align="center">${article.last_reply }</td>
					<td align="center">${article.last_reply_date }</td>
				</tr>
			</c:forEach>
			<tr><td colspan="8"></td></tr>
			<tr><td colspan="8" align="center">
			<c:choose>
				<c:when test="${page.pageNumber >1 }"><a href="#" onclick="page(${page.pageNumber-1})">上一页</a></c:when>
				<c:otherwise>
				</c:otherwise>
			</c:choose>
			<c:choose>
				<c:when test="${page.pageNumber <page.totalPage}"><a href="#" onclick="page(${page.pageNumber+1})">下一页</a></c:when>
				<c:otherwise></c:otherwise>
			</c:choose>
			当前第${page.pageNumber }页,共${page.totalPage}页,${page.totalRow }条记录。</td></tr>
			<%-- <c:if test="${username != 'admin'}"><tr><td colspan="5" align="center"><c:if test="${page.totalRow <50 }">你还有<font color="red">${50-page.totalRow }</font>个电话任务未完成，加油喔。</c:if></td></tr></c:if> --%>
		</table>
	</div></c:if>
	<c:if test="${page.totalRow == 0}">
		<div align="center" style="margin-top: 30px;">暂无记录。我要<a href="<%=basePath %>article/add">发帖</a></div>
	</c:if>
</div>
</body>
</html>